async function chunkedParseJson<T>(jsonString: string, chunkSize = 10000): Promise<T> {
    if (jsonString.length <= chunkSize) {
        return JSON.parse(jsonString);
    }

    // 简单检测JSON类型（数组或对象）
    const isArray = jsonString.trim().startsWith('[');
    let result: any = isArray ? [] : {};
    let position = 1; // 跳过起始的 [ 或 {
    let depth = 0;
    let chunkStart = 1;

    for (let i = 1; i < jsonString.length - 1; i++) {
        const char = jsonString[i];

        // 跟踪嵌套深度
        if (char === '{' || char === '[') depth++;
        if (char === '}' || char === ']') depth--;

        // 在顶层且遇到逗号或结束位置
        if (depth === 0 && (char === ',' || i === jsonString.length - 2)) {
            const chunk = jsonString.slice(chunkStart, char === ',' ? i : i + 1);
            if (chunk.trim()) {
                const parsed = JSON.parse(
                    isArray ? `[${chunk}]` : `{${chunk}}`
                );

                if (isArray) {
                    result.push(parsed[0]);
                } else {
                    Object.assign(result, parsed);
                }
            }

            chunkStart = i + 1;

            // 定期释放事件循环
            if (i % chunkSize === 0) {
                await new Promise(resolve => setImmediate(resolve));
            }
        }
    }

    return result as T;
}

// 使用示例

export default chunkedParseJson